package com.aspsine.multithreaddownload;

import com.aspsine.multithreaddownload.slice.DemoAbilitySlice;
import com.aspsine.multithreaddownload.slice.MainAbilitySlice;
import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;
import ohos.bundle.IBundleManager;
import ohos.security.SystemPermission;

public class DemoAbility extends Ability {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setMainRoute(DemoAbilitySlice.class.getName());
      //  requestPermissions();//apply permission
    }

    @Override
    public void onRequestPermissionsFromUserResult(int requestCode, String[] permissions,
                                                   int[] grantResults) {
        if (permissions == null || permissions.length == 0 || grantResults == null ||
                grantResults.length == 0) {
            return;
        }
        if (requestCode == 0) {
        }
    }

    public void requestPermissions(){
        if (verifySelfPermission(SystemPermission.WRITE_USER_STORAGE)
                != IBundleManager.PERMISSION_GRANTED) {
            requestPermissionsFromUser(new String[]{SystemPermission.WRITE_USER_STORAGE},0);
        }
    }
}
